﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public static class ContainerExtends
{
    public static T[] ToArray<T>(this HashSet<T> set)
    {
        T[] result = new T[set.Count];
        int j = 0;
        foreach (var a in set)
        {
            result[j] = a;
            j++;
        }
        return result;
    }

    public static void Add<T>(this HashSet<T> set, T[] arr)
    {
        for (int i = 0; i < arr.Length; i++)
        {
            set.Add(arr[i]);
        }
    }

    public static void Add<T>(this HashSet<T> set, HashSet<T> arr)
    {
        foreach (var i in arr)
        {
            set.Add(i);
        }
    }

    public static List<T> Clone<T>(this List<T> set)
    {
        List<T> r = new List<T>();
        r.Capacity = set.Count;
        for(int i = 0; i < set.Count; i++)
        {
            r.Add(set[i]);
        }

        return r;
    }
}
